From: Florian Müllner Date: Sun, 29 Mar 2020 17:36:12 +0000 (+0200) Subject: st/entry: Unset key focus when made unreactive X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~751^2^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6d3c740b376ce4ba1f344cccbeb1a5939a49e52c;p=gnome-shell.git st/entry: Unset key focus when made unreactive It seems reasonable that an entry shouldn't allow entering text when not reactive. The same could be achieved by changing the text's :editable property, however that will disable scrolling if the text doesn't fit, which may result in an unwanted size change. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423 --- diff --git a/src/st/st-entry.c b/src/st/st-entry.c index 2be524bb3..9391ffb80 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -513,6 +513,26 @@ st_entry_allocate (ClutterActor *actor, clutter_actor_allocate (priv->entry, &child_box, flags); } +static void +clutter_text_reactive_changed_cb (ClutterActor *text, + GParamSpec *pspec, + gpointer user_data) +{ + ClutterActor *stage; + + if (clutter_actor_get_reactive (text)) + return; + + if (!clutter_actor_has_key_focus (text)) + return; + + stage = clutter_actor_get_stage (text); + if (stage == NULL) + return; + + clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); +} + static void clutter_text_focus_in_cb (ClutterText *text, ClutterActor *actor) @@ -981,6 +1001,9 @@ st_entry_init (StEntry *entry) priv->entry, "reactive", G_BINDING_DEFAULT); + g_signal_connect(priv->entry, "notify::reactive", + G_CALLBACK (clutter_text_reactive_changed_cb), entry); + g_signal_connect (priv->entry, "key-focus-in", G_CALLBACK (clutter_text_focus_in_cb), entry);